function loadConfig()
{
	$.ajax({
		type: this.method,
		url: this.action,
		data: $(this).serialize(),
		dataType: 'json',
		success: showResults,
		error: function() { alert('Error while loading/unloading config!'); }
	});

	return false;
}

function showResults(json, textStatus)
{
	if (json.error) {
		alert(json.error);
		return;
	}

	alert('Configuration loaded successfully!');
	window.location.reload();
}

function init()
{
	$('#config_form').submit(loadConfig);
	$('#ajax_indicator').ajaxStart(function(){ $(this).show(); });
	$('#ajax_indicator').ajaxStop(function(){ $(this).hide(); });
}

$(init);
